2 #! nix shell --impure --expr ``
3 #! nix with (builtins.getFlake "git+file://${toString ./../..}/..").packages.${builtins.currentSystem};
5 #! nix (haskellPackages.ghcWithPackages (
6 #! nix haskellPackages: [
7 #! nix haskellPackages.pandoc-types
12 #! nix --command runhaskell
14 {-#LANGUAGE OverloadedStrings#-}
15 {-#LANGUAGE ViewPatterns #-}
16 import Text.Pandoc.JSON
17 import Data.List qualified as List
18 import Data.Text qualified as Text
21 main = toJSONFilter filt
23 filt :: Block -> Block
24 -- Put chapter images into the chapter
25 filt (Div as@(_, ["Section1"], _) es) = Div as (fixChapterImage es)
26 -- Remove useless images
27 filt (Para (Image _ _ ("Images/philos0.jpg", _):_)) = Para []
30 fixChapterImage (p@(Para
33 (Image ( _ , _ , _ ) _ ( Text.isPrefixOf "Images/Chapter" -> True , _ )
39 fixChapterImage (x:xs) = x:fixChapterImage xs
40 fixChapterImage [] = []
42 -- vim: syntax=haskell